﻿using NLog;
using NLog.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhonTai.Industry.Contracts.Model.Entity;

namespace ZhonTai.Industry.Core.Core.Common
{
    /// <summary>
    /// 共用内容
    /// </summary>
    public abstract class WorkExecuteBase
    {
        protected Logger logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();

        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public abstract Task ExecuteAsync(PushShip content);

        /// <summary>
        /// PLC方工站代号
        /// </summary>
        /// <param name="stationId"></param>
        /// <returns></returns>
        protected int StationAvatar(long stationId)
        {
            switch (stationId)
            {
                case 658772103925765:
                    return 85301;

                case 658772147601413:
                    return 85401;

                case 658773423542277:
                    return 85401;

                case 658772188913669:
                    return 85501;

                case 658773385228293:
                    return 85501;

                case 658772260032517:
                    return 85601;

                case 658772336660485:
                    return 856501;

                case 658772383137797:
                    return 85701;

                case 658773288931333:
                    return 85701;

                case 658772433727493:
                    return 85801;

                case 658773311492101:
                    return 85801;

                case 658772479676421:
                    return 85901;

                case 658773329854469:
                    return 85901;

                case 658772513284101:
                    return 851001;

                case 658773348499461:
                    return 851001;

                case 658771567214597:
                    return 3001;

                case 658771724410885:
                    return 3001;

                case 658771833319429:
                    return 4001;

                case 658771886141445:
                    return 7001;

                case 658772019912709:
                    return 8001;

                case 658773061001221:
                    return 8001;

                case 658772754747397:
                    return 9001;

                case 658773100728325:
                    return 9001;

                case 658772796923909:
                    return 11001;

                case 658773148561413:
                    return 11001;

                case 658772820852741:
                    return 12001;

                case 658773173587973:
                    return 12001;

                case 658772847173637:
                    return 13001;

                case 658773195304965:
                    return 13001;

                case 658772878184453:
                    return 14001;

                case 658773219594245:
                    return 14001;

                case 658773461307397:
                    return 17001;

                case 658773511680005:
                    return 17001;

                case 658773488828421:
                    return 18001;

                case 658773535571973:
                    return 18001;

                case 658772907999237:
                    return 19001;

                case 658773248839685:
                    return 19001;

                default:
                    return -1;
            }
        }

        /// <summary>
        /// 动态数据转换
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        protected string DynamicToString(dynamic data)
        {
            return data == null ? "" : (string)data.ToString();
        }
    }
}